package com.tyqx.hashchainbiz.controller;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/*@EnableSwagger2
//@EnableWebMvc
@ComponentScan(basePackages = {"com.tyqx.hashchainutil","com.tyqx.hashchainbiz.*"})
@Configuration  // beans
//WebMvcConfigurationSupport,*/
@Configuration
@EnableSwagger2
public class  SwaggerConfig extends WebMvcConfigurerAdapter {

    /*public void addResourceHandlers(ResourceHandlerRegistry registry){
        registry.addResourceHandler("swagger-ui.html")
                .addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars").addResourceLocations("classpath:/META-INF/resources/webjars");
    }*/


    @Bean
    public Docket createDocket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(getApiInfo()) //API信息
                .select() //扫描哪个路径下的哪些API
                .apis(RequestHandlerSelectors.basePackage("com.tyqx.hashchainbiz.controller"))
                .paths(PathSelectors.any())//任何路径
                .build();
    }

    private ApiInfo getApiInfo() {
        return new ApiInfoBuilder().title("dcep-spring项目Biz主业务模块")
                .contact(new Contact("lhb", "", ""))
                .version("V1.0").build();
    }


}
